package com.xueyi.core.aop;

import com.xueyi.core.base.AesResponse;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

/**
 * @author 俞烨
 * @version 1.0
 * @description: AES切面类
 * @date 2023/11/26 20:48
 */
@Aspect
@Component
public class AesAspect {

    /**
     * AES切面
     *
     * @param pjp
     * @return
     * @throws Throwable
     */
    @Around("@annotation(com.xueyi.core.annotations.Aes)")
    public Object aesAspect(ProceedingJoinPoint pjp) throws Throwable {

        Object proceed = pjp.proceed();
        if ("true".equals(System.getProperty("openAes"))) {
            return AesResponse.aes(proceed);
        }

        return proceed;
    }
}
